/*未完成*/
;(function(window){

	function badCharacter(pat, char, charIndex){
		return charIndex - pat.indexOf(char);
	}

	function goodSuffix(chars){
		console.log(chars);
	}

	function substrSearch(string, pat, start, patLn, max){
		var substr = string.substr(start, patLn),
				ln = patLn- 1,
				i = ln, badCharIdx,next;
		console.log(start+':'+substr);
		for(;i>-1;i--){
			if( substr[i] != pat[i]  ){
				if( i == ln ){
					badCharIdx = badCharacter(pat, substr[i], i);
					next = start+badCharIdx;
					substrSearch(string, pat, next, patLn, max);
					break;
				}
			}else{
				console.log(substr.substring(i,ln));
			}
		}

	}

	window.BoyerMooreSearch = function(string, pat){
		substrSearch(string, pat, 0, pat.length, string.length);
	};
})(window);